package com.sailing.core.java;

import java.security.InvalidParameterException;
import java.util.Arrays;

public class BaseTypeDataTransferTest {
    public static final int ALLDEPOSIT = -1;
    private void doTransfer(Integer input){

        int refundAmount = input == null ? 0 : input;
        if ( refundAmount == 0) {
            // 剩余全退
            refundAmount = ALLDEPOSIT;
        }
        System.out.println(String.format("before invoke transferAnother refundAmount :%d", refundAmount));
        transferAnother(refundAmount);
        System.out.println(String.format("after invoke transferAnother refundAmount :%d", refundAmount));
    }

    private void transferAnother(int refundAmount){
        int remainingDepositAmount = 10;

        // 请求退款金额
        if (refundAmount == ALLDEPOSIT) {
            // 剩余全退
            refundAmount = remainingDepositAmount;
            System.out.println(String.format("in transferAnother reset refundAmount :%d", refundAmount));
        }

    }

    public static void main(String[] args) {
        Integer[] inputs = new Integer[]{null, -1, 0, 1, 100};


        for (Integer input : inputs){
            System.out.println(String.format("current input %d", input));
            new BaseTypeDataTransferTest().doTransfer(input);

            System.out.print("\n***************************\n");
        }


    }

}
